1. Field of the Invention
Embodiments of the present invention generally relate to computer processors and execution of instructions within computer processors.
2. Description of the Related Art
Computers typically include a main memory for storing programs and a processor for executing the programs stored in the main memory. During execution of the programs, the processor may be configured to load instructions for a program into one or more memories which are typically smaller than the main memory, usually referred to as a cache, from which the processor may execute the program instructions.
In some cases, a given processor may be configured to execute multiple threads of execution, referred to as multithreading. Execution of each thread may be performed concurrently and/or sequentially within the processor. Each thread may, for example, be used to perform a task. For example, a plurality of threads may be used to execute an application such as a video game which performs three-dimensional graphics rendering, sound effects, physics simulations, player input/output, and other functions.
To provide the most realistic experience to the video game player, there may be a desire to have each thread perform a given function (e.g., one thread may draw a three-dimensional scene, also referred to as rendering while another thread performs a physics calculation) requiring a certain amount of processing power for a set amount of time. For example, if the processor is being used to render a three-dimensional sequence of an action being performed by a video game player in a video game, there may be a desire to render each picture (referred to as a frame) in the sequence quickly such that the action appears to occur smoothly (e.g., if the action being performed by a video game player is a jump, there may be a desire for the jump to appear smoothly up and down as would a real-life jump).
During execution of multiple threads, there may be a desire to share information such as data and/or instructions between each thread. For example, with respect to the video game example described above, a thread performing a physics calculation may share information with a thread which is rendering a scene so that the rendered scene accurately depicts the results of the physics calculation. In some cases, each executing thread may also be in competition for cache space within the processor. For example, a first thread which loads information into the processor cache may displace information (e.g., send the information back to main memory) which is used by a second thread. If the second thread subsequently attempts to access the displaced information, the second thread may pause execution while the displaced information is retrieved from the main memory, thereby reducing the processing power provided to the second thread.
Thus, there is typically a desire to have one or more threads in a processor collectively executing as many instructions as possible (thereby providing maximum processing power). Where multiple threads are executing in the processor, there is also typically a desire to provide sufficient capability in the processor so that each thread can share information while avoiding contention for memory space within the processor. Accordingly, what are needed are improved methods and apparatuses for executing instructions in a processor.